home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0232_Re: RTF -> plain text.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-03-04  |  1009 b   |  36 lines

  1. {
  2. > I use a RichEdit in one of my apps with plaintext set to false, since
  3. > I do some color coding. Now, when I copy RTF text from e.g. Word and
  4. > paste it into my app, the size and font is also pasted, but I just
  5. > want the text without RTF information.
  6. <snip>
  7. > What would be the proper way to paste just the plaintext of RTF text
  8. > in the clipboard into the RichEdit?
  9.  
  10. Proper? I don't know about its propriety, but the following routine
  11. works.
  12.  
  13. Please note that this doesn't override the rich edit control's
  14. standard paste function, so sending it a WM_PASTE message, (by
  15. pressing Ctrl-V, perhaps) will still paste formatted text.
  16. }
  17.  
  18. procedure PasteTextOnly(dest: TRichEdit);
  19. var
  20.   MyHandle: THandle;
  21.   TextPtr: PChar;
  22. begin
  23.   ClipBoard.Open;
  24.   Try
  25.     MyHandle := Clipboard.GetAsHandle(CF_TEXT);
  26.     TextPtr := GlobalLock(MyHandle);
  27.     try
  28.       dest.SetSelTextBuf(TextPtr);
  29.     finally
  30.       GlobalUnlock(MyHandle);
  31.     end;
  32.   finally
  33.     Clipboard.Close;
  34.   end;
  35. end;
  36.